#!/bin/bash


#Declare some variables:
adt_directory="/Applications/Adobe Flash Builder 4.6/sdks/4.6.0/bin"


pushd $1

native_library=$2
library_name=$3
native_directory=$4
build_type=$5

library_directory="../../""${library_name}"
dest_ANE="${library_name}".ane
extension_XML="${library_name}"-extension.xml
platform_options_XML="${library_name}"-ios-platformoptions.xml
library_SWC="${library_name}".swc


#Clean up the terrain from old packages:
rm -f *.*


#Copy the ingredients for the package:
cp -f "${native_directory}"/build/"${build_type}"-iphoneos/"${native_library}" .
cp -f "${library_directory}"/src/"${extension_XML}" .
cp -f "${library_directory}"/src/"${platform_options_XML}" .
cp -f "${library_directory}"/bin/"${library_name}".swc .

unzip -o "${library_name}".swc
rm -f catalog.xml


#Make the package:
"${adt_directory}"/adt -package -target ane "${dest_ANE}" "${extension_XML}" -swc "${library_SWC}" -platform iPhone-ARM -C . . -platformoptions "${platform_options_XML}"

rm -f *.xml
rm -f *.swf
rm -f *.a
rm -f *.swc

popd


